<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<jsp:useBean id="pageBean" scope="request" class="com.agileai.hotweb.domain.PageBean"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>流程仿真</title>
<%@include file="/jsp/inc/resource.inc.jsp"%>
<script language="javascript">
function addRow(){
	doSubmit({actionType:'addBizData',doValidate:'false'});
}
function deleteRow(index){
	$("#bizDataIndex").val(index);
	doSubmit({actionType:'delBizData',doValidate:'false'});
}

var processListBox;
function showProcessList(){
	if (!processListBox){
		processListBox = new PopupBox('processListBox','流程列表信息',{size:'big'}); 
	}
	processListBox.sendRequest('index?WfProcessDefineSelect&targetId=WFP_ID&targetName=WFP_NAME');
}

var varIndex = 0;
var prcocessVarListBox;
function showPrcocessVarList(index){
	if (!isValid($('#WFP_ID').val())){
		alert('请选择流程！');
		return;
	}
	varIndex = index;
	if (!prcocessVarListBox){
		prcocessVarListBox = new PopupBox('prcocessVarListBox','请选择流程变量',{size:'big'}); 
	}
	prcocessVarListBox.sendRequest('index?WfProcessVariableSelect&WFP_ID='+$('#WFP_ID').val());
}

function fillProcessVar(lable,code,value){
	$("#bizDataName_"+varIndex).val(lable);
	$("#bizDataCode_"+varIndex).val(code);
	$("#bizDataValue_"+varIndex).val(value);
}

function submitProcess(){
	var bizDataSize = parseInt($('#bizDataSize').val());
	for (var i=0;i < bizDataSize;i++){		
		var code = $('#bizDataCode_'+i).val();
		var name = $('#bizDataName_'+i).val();
		var value = $('#bizDataValue_'+i).val();		
		if (validation.checkNull(code) || validation.checkNull(name)
			|| validation.checkNull(value)){
			writeErrorMsg('字段名称、字段编码、编码值都不能为空！');
			return;			
		}
		if (!validation.isRawChar(code)){
			writeErrorMsg('字段编码只能由数字、字母或者下划线组成！');
			ele('bizDataCode_'+i).focus();
			return;
		}	
	}
	doSubmit({actionType:'submit'});
}
function backToList(){
	<%
	if (pageBean.getBoolValue("comeFromTaskList")){
	%>
	window.location.href="index?TaskListQuery";
	<%}else{%>
	goToBack();
	<%}%>
}
</script>
</head>
<body>
<form action="<%=pageBean.getHandlerURL()%>" name="form1" id="form1" method="post">
<%@include file="/jsp/inc/message.inc.jsp"%>
<div id="__ParamBar__" style="float: right;">&nbsp;</div>
<div id="__ToolBar__">
<table border="0" cellpadding="0" cellspacing="1">
<tr height="24px;">
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onClick="submitProcess()"><input value="&nbsp;" type="button" class="transImgBtn" id="transImgBtn" title="提交" />提交</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onClick="backToList();"><input value="&nbsp;" type="button" class="backImgBtn" title="返回" />返回</td>
</tr>
</table>
</div>
<table class="detailTable" cellspacing="0" cellpadding="0">
<tr>
	<th width="100" nowrap>流程</th>
	<td><input label="流程" name="WFP_NAME" type="text" class="text" id="WFP_NAME" value="<%=pageBean.inputValue("WFP_NAME")%>" size="24" readonly="readonly" ondblclick="showProcessList()" /><input id="WFP_ID" name="WFP_ID" type="hidden" value="<%=pageBean.inputValue("WFP_ID")%>" size="24"/><img src="images/query.gif" width="16" height="16" onclick="showProcessList()" style="cursor:pointer" /></td>
</tr>
<tr>
	<th width="100" nowrap>标题</th>
	<td><input label="标题" id="WFE_TITLE" name="WFE_TITLE" type="text" value="<%=pageBean.inputValue("WFE_TITLE")%>" size="24" class="text" />
</td>
</tr>
<tr>
	<th width="100" nowrap>描述</th>
	<td><textarea name="WFE_REMARK" cols="40" rows="3" class="text" id="WFE_REMARK"><%=pageBean.inputValue("WFE_REMARK")%></textarea>
    </td>
</tr>
<tr>
	<th width="100" nowrap>&nbsp;</th>
	<td style="text-align:left"><input name="SKIP_FIRST_NODE" type="checkbox" id="SKIP_FIRST_NODE" value="true" checked="checked" /><label for="checkbox">跨域首节点</label></td>
</tr>
</table>
<table id="dataTable" class="dataTable" cellspacing="0"  cellpadding="0">
  <tr>
    <th width="30%" align="center" nowrap="nowrap">名称</th>
    <th width="30%" align="center">字段编码</th>
    <th width="30%" align="center" nowrap="nowrap">字段值</th>
    <th width="80" align="center" nowrap="nowrap"><input class="formbutton"type="button" name="button7" id="button7" value="新增" onClick="addRow()"/></th>
  </tr>
<%
pageBean.initListAttribute("bizDataList");
int varSize = pageBean.listSize();
for (int i=0;i < varSize;i++){
%>  
  <tr>
    <td align="center" nowrap="nowrap" ondblclick="showPrcocessVarList(<%=i%>)"><input name="bizDataName_<%=i%>" type="text" id="bizDataName_<%=i%>" value="<%=pageBean.inputValue(i,"bizDataName") %>" size="20" readonly="readonly" /></td>
    <td align="center"><input name="bizDataCode_<%=i%>" type="text" id="bizDataCode_<%=i%>" value="<%=pageBean.inputValue(i,"bizDataCode") %>" size="16" maxlength="16" readonly="readonly"/></td>
    <td align="center"><input name="bizDataValue_<%=i%>" type="text" id="bizDataValue_<%=i%>" value="<%=pageBean.inputValue(i,"bizDataValue") %>" size="20" maxlength="20" /></td>
    <td align="center" nowrap="nowrap" style="text-align:center"><input class="formbutton" type="button" name="delBtn_<%=i%>" id="delBtn_<%=i%>" value="删除" onclick="deleteRow(<%=i%>)"/></td>
  </tr>
<%}%>
</table>
<input type="hidden" name="bizDataSize" id="bizDataSize" value="<%=pageBean.inputValue("bizDataSize") %>"/>
<input type="hidden" name="actionType" id="actionType" value=""/>
<input type="hidden" name="operaType" id="operaType" value="<%=pageBean.getOperaType()%>"/>
<input type="hidden" name="bizDataIndex" id="bizDataIndex" value=""/>
<input type="hidden" name="WFE_ID" id="WFE_ID" value="<%=pageBean.inputValue("WFE_ID")%>"/>
<input type="hidden" name="WFIP_ID" id="WFIP_ID" value="<%=pageBean.inputValue("WFIP_ID")%>"/>
<input type="hidden" name="WFA_CODE" id="WFA_CODE" value="<%=pageBean.inputValue("WFA_CODE")%>"/>
</form>
<script language="javascript">
requiredValidator.add("WFP_NAME","WFE_TITLE");
lengthValidators[1].set(64).add("WFE_TITLE");
lengthValidators[2].set(512).add("WFE_REMARK");
$('#form1').css({height:'500px'});
</script>
</body>
</html>
<%@include file="/jsp/inc/scripts.inc.jsp"%>
